#include "symbol.h"


void symbol_print(struct symbol* s)
{
  if (!s) return;
/*  switch (s->kind)
  {
    case SYMBOL_KIND_LOCAL:
      printf("LOCAL %d", s->which);
      break;
    case SYMBOL_KIND_PARAM:
      printf("PARAM %d", s->which);
      break;
    case SYMBOL_KIND_GLOBAL:
      printf("GLOBAL %s", s->);
      break;
  }
*/
}

struct symbol * symbol_create ( 
  int kind, 
  int which, 
  struct type * type, 
  char * name,
  int isDefined
  )
{
  struct symbol *a = malloc(sizeof(*a));

	a->kind = kind;
	a->which = which;
	a->type = type;
	a->isDefined = isDefined;
	a->name = name;
	return a;

}

char * symbol_code(struct symbol * s)
{
  static char str[100];
  switch (symbol->kind)
  {
  case SYMBOL_KIND_LOCAL:
    snprintf(str, sizeof(str), "-%d(%%ebp)", (s->which+1)*4);
    break;
  case SYMBOL_KIND_PARAM:
    snprintf(str, sizeof(str), "+%d(%%ebp)", (s->which+2)*4);
    break;
  case SYMBOL_KIND_GLOBAL:
    snprinf(str, sizeof(str), "%s", s->name);
    break;
  }
  return str;
}



